var express = require('express')
var connection = require('../db/db_utill');

var router = express.Router()

//获取话题评论内容
router.get('/get_topic_author', function (req, res) {
  //获取url发送用户点击话题的id
  var id = req.query.id

  connection.query(`SELECT t2.user_id,username,self_sign,header_pic FROM 
  topic_info t1,
  user_info t2
  WHERE t1.topic_id = ?
  and t1.user_id=t2.user_id`, [id], function (error, results, fields) {
    if (error) {
      throw error;
    } else if (results.length) {
      var string = JSON.stringify(results);
      var jsons = JSON.parse(string)[0];
      res.json(jsons)
    }
  });
})

module.exports = router;
